﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using OnlineCourse.JWTAuthorizePolicy;
using OnlineCourse.Model;

namespace OnlineCourse.API.Controllers
{
    [Route("api/[controller]")]
    [ApiController]
    public class SectionController : ControllerBase
    {
        private readonly PermissionRequirement _requirement;
        private readonly Services.SectionService _usbll;
        public SectionController(ApplicationDbContext db, PermissionRequirement requirement)
        {

            _requirement = requirement;
            _usbll = new Services.SectionService(db);
        }
        /// <summary>
        /// 添加单门课程详细信息
        /// </summary>
        /// <param name="courseId"></param>
        /// <param name="title"></param>
        /// <param name="type"></param>
        /// <param name="path"></param>
        /// <param name="detailed"></param>
        /// <param name="TryReading"></param>
        /// <returns></returns>
        [HttpPost("Add")]
        public IActionResult Add(Guid courseId, string title, int type, string path, string detailed, bool TryReading)
        {
            bool mark = _usbll.Add(courseId, title, type, path, detailed, TryReading);

            return Ok(mark);
        }
        /// <summary>
        /// 修改单门课程信息
        /// </summary>
        /// <param name="id"></param>
        /// <param name="courseId"></param>
        /// <param name="title"></param>
        /// <param name="type"></param>
        /// <param name="path"></param>
        /// <param name="detailed"></param>
        /// <param name="TryReading"></param>
        /// <returns></returns>
        [HttpPut("Update")]
        public IActionResult Update(Guid id, Guid courseId, string title, int type, string path, string detailed, bool TryReading)
        {
            bool mark = _usbll.Update(id,courseId ,title ,type ,path ,detailed ,TryReading);
            return Ok(mark);
        }
        /// <summary>
        /// 删除单门课程
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        [HttpDelete ("Delete")]
        public IActionResult Delete(Guid id)
        {
            bool mark = _usbll.Delete(id);
            return Ok(mark);
        }
    }
}